<?php
get_header();
?>
<div id="main-content" class="main-content tintuc-page">
    <div id="page-tintuc" class="content-area pagewidth">
        <div id="tinmoi">
            <?php
            $i = 0;
            while (have_posts()) : the_post();
                ?>
                <div id = "<?php
                if ($i == 0) {
                    echo 'noibat';
                } else {
                    echo 'listtin';
                }
                ?>">
                         <?php
                         if ($i == 0) {
                             ?>
                        <div class="noibatimgdiv cboth">
                            <div class="img_noibat">
                                <?php
                                if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it.
                                    the_post_thumbnail(array(480, 280));
                                }
                                ?>
                                <img src="<?php echo get_template_directory_uri(); ?>/images/icon_tinmoinhat.png" class="icon_noibat"/>
                            </div>
                        </div>

                        <div class="noibat_dec">
                            <a href="<?php echo get_permalink(get_the_ID()); ?>" class="cboth"><?php the_title(); ?></a>
                            <p> 
                                <?php echo the_excerpt(get_the_content()); ?>
                            </p>
                        </div>

                        <?php
                        $i++;
                        ?>
                    </div>      
                    <?php
                } else {
                    ?>
                    <div id="listtin">
                        <div class="item-news">
                            <?php
                            if (has_post_thumbnail()) {
                                the_post_thumbnail('thumbnail');
                            }
                            ?>
                            <div class="title_news"><a href="<?php echo get_permalink(get_the_ID()); ?>"><?php the_title(); ?></a></div>
                            <div class="item_dec">
                                <?php echo the_excerpt(get_the_content()); ?>
                            </div>
                        </div>
                        <?php
                    }
                endwhile;
                ?>
            </div>

        </div>
        <ul id="cactinkhac" class="cboth">
            <?php
            $args = array('order_by' => 'rand()', 'posts_per_page' => 3);
            query_posts($args);
            while (have_posts()) : the_post();
                ?>
                <li><a href="<?php echo get_permalink(get_the_ID()); ?>"><?php the_title(); ?></a></li>
                <?php
            endwhile;
            ?>
        </ul>
    </div>

</div>


</div><!-- #primary -->
</div><!-- #main-content -->
<script src="<?php echo get_template_directory_uri(); ?>/js/jquery.js"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/jquery.mCustomScrollbar.min.js"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/jquery.mousewheel.min.js"></script>

<script>

    $(window).load(function() {

        $("#listtin").mCustomScrollbar({
            theme: "dark"
        });

    });

</script>
<?php get_footer(); ?>